package com.justreading.nio;

import java.nio.IntBuffer;

/**
 * @author LYJ
 * @Description
 * @date 2021 年 09 月 29 日 下午1:58
 */
public class BasicBuffer {

    public static void main(String[] args) {
        IntBuffer intBuffer = IntBuffer.allocate(5);
        for (int i = 0; i < intBuffer.capacity() ; i++) {
            intBuffer.put(i);
        }

        //切换
        intBuffer.flip();

        //读取
        while (intBuffer.hasRemaining()){
            System.out.println("读取到的缓冲区数据:" + intBuffer.get());
        }
    }
}
